{extend name="index:layout" /}

{block name="menu"}{/block}

{block name="content"}
<SCRIPT LANGUAGE="JavaScript">
<!--
function upfile(url,name,size,ty){
	document.getElementById(ty).value=url;
}
function SelectType(i){
	$('#selecttype0').hide();
	$('#selecttype1').hide();
	$('#selecttype'+i).show();
}
function addType(){
	var list1=$('.ListType').children().length;
	var ListType1='<div class="list"><div><span>标题</span> <input name="answers['+list1+'][title]" type="text" size="50"/></div><div><span>描述</span> <textarea name="answers['+list1+'][desc]" cols="50" rows="3"></textarea></div><div><span>图片</span> <input name="answers['+list1+'][pic]" type="text" id="out_url'+list1+'" placeholder="请上传图片" size="50"/><em><iframe frameborder=0  scrolling=no src="$webdb[www_url]/do/upfile.php?fn=upfile&dir=weixinautoreply&label=out_url'+list1+'"></iframe></em></div><div><span>链接</span> <input name="answers['+list1+'][link]" type="text" size="50"/> (必填项)</div></div>';
	$(".ListType").append(ListType1);
	hide_desc();
}
function hide_desc(){
	$('.ListType .list').each(function(){
		$(this).children().eq(1).hide();
	});
}
//-->
</SCRIPT>  
<style>
.ListType .list{border:#DDD solid 1px;margin:2px auto 3px auto;background:#EFEFEF;}
.ListType .list div{border-top:#DDD solid 1px;padding:5px 5px 5px 50px;position:relative;}
.ListType .list div span{display:block;width:45px;height:30px;line-height:30px;text-align:right;position:absolute;top:0;left:0;}
.ListType .list div input{width:200px;border:#DDD solid 1px;height:20px;}
.ListType .list div textarea{border:#DDD solid 1px;height:100px;width:90%;} 
.ListType .list div em{display:block;width:300px;height:28px;position:absolute;left:260px;top:3px;overflow:hidden;}
</style>
<form method="post" action="index.php?lfj=$lfj&action=addword">
<div class="MainContainers">
	<div class="Header"><span class="tag">添加关键字</span><span class="more">&gt;&gt;</span></div>
    <table class="FormTable">
		<tr> 
			<td class="tdL">关键词：</td>
			<td class="tdR"><input name="ask" type="text" style="width:200px;border:#DDD solid 1px;height:20px;"/>（多个个关键词，请用半角空格隔开）</td>
		</tr>
		<tr>
			<td class="tdL">内容类型：</td>
			<td class="tdR">
				<input name="type" type="radio" value="1" onClick="SelectType(1)"> 图文 
				<input name="type" type="radio" onClick="SelectType(0)" value="0" checked="checked"> 纯文本
			</td>
		</tr>
		<tr id='selecttype0'>
			<td class="tdL">回复内容：</td>
			<td class="tdR"><textarea name="answer" style="border:#DDD solid 1px;height:100px;width:90%;"></textarea></td>
		</tr>
		</tr>
		<tr id='selecttype1' style="display:none;">
			<td class="tdL">回复内容：<img src='$webdb[www_url]/images/default/menu_add.gif' onClick="addType()"/></td>
			<td class="tdR">
				<div class="ListType">
					<div class="list">
						<div><span>标题</span> <input name="answers[0][title]" type="text"/></div>
						<div><span>描述</span> <textarea name="answers[0][desc]"></textarea></div>
						<div>
							<span>图片</span> <input name="answers[0][pic]" type="text" id='out_url0' placeholder="请上传图片"/>
							<em><iframe frameborder=0  scrolling=no src='$webdb[www_url]/do/upfile.php?fn=upfile&dir=weixinautoreply&label=out_url0'></iframe></em>
						</div>
						<div><span>链接</span> <input name="answers[0][link]" type="text"/> (必填项)</div>
					</div>
				</div>
			</td>
		</tr>
    </table>
	<div class="submits"><input type="submit" name="Submit2" value="提交" /></div> 
</div>
</form>

<form name="form_work" method="post" action="index.php?lfj=$lfj&action=delete">
<div class="MainContainers">
	<div class="Header"><span class="tag">内容列表</span><span class="more">&gt;&gt;</span></div>
	<div class="Conter">
        <table class="ListTable">
	<tr>
            <th width="50">排序值</th>
            <th width="200">关键词</th>
            <th width="80">内容类型</th>
	  <th>回复内容</th>
	  <th width="80">修改</th>
            <th width="80">删除</th>
	 <th width="80"></th>
          </tr>
{php}
foreach($listdb AS $key=>$rs){
{/php}
    <tr> 
      <td>$rs[list]</td>
      <td class='Left'><input type="checkbox" name="iddb[{$rs[id]}]" value="{$rs[id]}"> $rs[ask]</td>
     <td class='Left'>$rs[types]</td>
      <td class='Left'>$rs[answer]</td>
	  <td><a href="index.php?lfj=$lfj&job=edit&id=$rs[id]" class="edit">修改</a></td>
	  <td><a href="index.php?lfj=$lfj&action=delete&iddb[{$rs[id]}]=$rs[id]" class="del">删除</a></td>
      <td><a href="index.php?lfj=$lfj&job=add"></a></td>
    </tr> 
{php}
}
{/php}
  </table>
		<div align="center">$showpage</div>
		<div class="submits">
			<input type="button" onclick="CheckAll('all')" name="Submit2" value="全选" />
			<input type="button" onClick='CheckAll()' name="Submit2" value="反选" /> 
			<!-- <a href="#" onClick="CheckAll('all')">全选</a> -->
			<!-- <a href="#" onClick='CheckAll()'>反选</a> -->
			<input type="submit" name="Submit" value="删 除">
		</div>
	</div>
</div>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!--
function postdo(va){
	document.form_work.jobs.value=va
	document.form_work.submit();
}
function CheckAll(va){
	form=document.form_work
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(va=='all'){
			e.checked = true;
		}else{
			e.checked == true ? e.checked = false : e.checked = true;
		}
	}
}
//-->
</SCRIPT>
<div class="MainContainers">
	<div class="Header"><span class="tag">帮助说明</span></div>
	<div class="Conter">
		<ul class="notes">
		<li>1、这里可以设置类似机器人回复微信用户提出的问题，你可以设置关键词，根据用户提出的问题中包含此关键字时，就回复对应的内容。回答不上的内容，就发给客服回复.</li>
		<li>2、排在最前面的会优先匹配。</li>
		</ul>
	</div>
</div>
{/block}